local scx, scy = guiGetScreenSize()
local setspeed = 10
local onspeed = 10

addEventHandler("onClientRender", getRootElement(), function()
	if getPedOccupiedVehicle(getLocalPlayer()) then
		local SPEED = math.floor(getElementSpeed(getPedOccupiedVehicle(getLocalPlayer())))
		dxDrawText(SPEED.." KM/H", 0, 0, scx, 100, tocolor(255, 255, 255), 1, "sans", "center", "bottom", false, false, false)
		if SPEED > onspeed and SPEED < setspeed + 5 then
			--setElementSpeed(getPedOccupiedVehicle(getLocalPlayer()), 0, setspeed)
		end
	end
end)

addCommandHandler("speed", function(cmd, outspeed) setspeed = tonumber(outspeed) end)
addCommandHandler("onspeed", function(cmd, outspeed) onspeed = tonumber(outspeed) end)

addEventHandler("onClientResourceStart", getResourceRootElement(), function()
	--local bg = guiCreateStaticImage(100, 100, 300, 300, "FILES/SPEEDO/bg.png", false)
	--local pfeil = guiCreateStaticImage(100, 100, 300, 300, "FILES/SPEEDO/pfeil.png", false)
end)

addEventHandler("onClientRender", getRootElement(), function()
	--local bg = dxDrawImage(scx - 400, scy - 220, 200, 200, "FILES/SPEEDO/bg.png")
	--if getPedOccupiedVehicle(getLocalPlayer()) then
	--	local SPEED = math.floor(getElementSpeed(getPedOccupiedVehicle(getLocalPlayer())))
	--	local pfeil = dxDrawImage(scx - 400, scy - 220, 200, 200, "FILES/SPEEDO/pfeil.png", SPEED)
		--local text = dxDrawText(SPEED, 100+SPEED, 100, 100, 100, tocolor(0,0,0))
		--local text = dxDrawText(SPEED, math.cos(math.rad(alpha)) * 110, math.sin(math.rad(alpha)) * 110, 100, 100, tocolor(0,0,0))
	--end
end)